//
//  UIView+LoadingOrBlank.h
//  FlagForiOS
//
//  Created by 容贤郁 on 2016/12/10.
//  Copyright © 2016年 Minidai. All rights reserved.
//

#import <UIKit/UIKit.h>

@class SYLoadingView, SYBlankPageView;

typedef NS_ENUM(NSInteger, SYBlankPageType) {
    
    SYBlankPageTypeNetworkError = 0,      //网络错误
    SYBlankPageTypeError        = 1,      //普通错误
    SYBlankPageTypeServerError,           //服务器错误
    SYBlankPageTypeTimeOut,               //请求超时
    SYBlankPageTypeNetworkLost,           //网络无法连接
    SYBlankPageTypeCannotConnectToServer, //服务器无法连接
    SYBlankPageTypeNoData,                //无数据
    SYBlankPageTypeNoCoupon,              //无加息券
    SYBlankPageTypeNoMessage,             //无消息
    SYBlankPageTypeNoComment              //无评论
};

//loading页面和网络错误或者数据为空时显示
@interface UIView (LoadingOrBlank)

#pragma mark LoadingView
@property (strong, nonatomic) SYLoadingView *loadingView;
#pragma mark BlankPageView
@property (strong, nonatomic) SYBlankPageView *blankPageView;

/** 开始loading */
- (void)beginLoading;
/** loading结束 */
- (void)endLoading;
/** 显示空白页面 当reloadButtonBlock为nil时页面不能点击 */
- (void)configBlankPage:(SYBlankPageType)blankPageType hasData:(BOOL)hasData  reloadButtonBlock:(void(^)(id sender))block;

- (SYBlankPageType)blankPageTypeWithError:(NSError *)error;

@end

#pragma mark - SYLoadingView

@interface SYLoadingView : UIView

//loading
@property (strong,nonatomic) UIImageView *loopView,*monkeyView;
@property (assign, nonatomic, readonly) BOOL isLoading;
/** 开始动画 */
- (void)startAnimating;
/** 结束动画 */
- (void)stopAnimating;

@end

#pragma mark - SYBlankView

@interface SYBlankPageView : UIView

/** 空白页面显示的image */
@property (strong, nonatomic) UIImageView *imgView;
/** 提示文字 */
@property (strong, nonatomic) UILabel *tipLabel;

/** 提示文字 */
@property (strong, nonatomic) UIButton *investButton;


/** 点击重新加载的block */
@property (copy, nonatomic) void(^reloadButtonBlock)(id sender);
/** 当reloadButtonBlock为nil时页面不能点击 */
- (void)configWithType:(SYBlankPageType)blankPageType hasData:(BOOL)hasData reloadButtonBlock:(void (^)(id))block;

@end
